package dev.ece.suit.ui;

import java.awt.image.BufferedImage;
import java.io.FileNotFoundException;
import java.io.IOException;

import dev.ece.core.cells.model.AbstractUI;
import dev.ece.core.shader.DefaultTextureShader;
import dev.ece.core.texture.Texture;
import dev.ece.suit.ui.shader.AlphaTextureShader;
import dev.ece.util.lib.IntOffset;
import dev.ece.util.lib.IntRectangle;
import dev.ece.util.obj.ObjectCount;

public class Image extends ContentItem {

	/**
	 * 
	 */
	private static final long serialVersionUID = 4203407717090760977L;

	private float alpha = 1f;
	
	public Image(AbstractUI<Float> ui, BufferedImage background) {
		super(ui, background);
	}

	public Image(AbstractUI<Float> ui, ObjectCount<Texture> background) {
		super(ui, background);
	}

	public Image(AbstractUI<Float> ui, String background) throws IOException {
		super(ui, background);
	}

	public Image(BufferedImage image, float width, float height) {
		super(image, width, height);
	}

	public Image(BufferedImage image, IntRectangle textureClipping, float width, float height, IntRectangle centerClipping) {
		super(image, textureClipping, width, height, centerClipping);
	}

	public Image(BufferedImage image, IntRectangle textureClipping, float width, float height) {
		super(image, textureClipping, width, height);
	}

	public Image(BufferedImage image, float width, float height, IntRectangle centerClipping) {
		super(image, width, height, centerClipping);
	}

	public Image(ObjectCount<Texture> background, float width, float height) {
		super(background, width, height);
	}

	public Image(ObjectCount<Texture> background, float width, float height, IntRectangle centerClipping) {
		super(background, width, height, centerClipping);
	}

	public Image(ObjectCount<Texture> background, IntRectangle textureClipping, float width, float height,
			IntRectangle centerClipping) {
		super(background, textureClipping, width, height, centerClipping);
	}

	public Image(ObjectCount<Texture> background, IntRectangle textureClipping, float width, float height) {
		super(background, textureClipping, width, height);
	}

	public Image(String background, float width, float height) throws IOException {
		super(background, width, height);
	}

	public Image(String background, IntRectangle textureClipping, float width, float height, IntRectangle centerClipping)
			throws IOException {
		super(background, textureClipping, width, height, centerClipping);
	}

	public Image(String background, float width, float height, IntRectangle centerClipping) throws IOException {
		super(background, width, height, centerClipping);
	}
	
	public Image(String background, IntRectangle textureClipping, float width, float height) throws IOException {
		super(background, textureClipping, width, height);
	}

	public Image(BufferedImage image, float width, float height, IntOffset centerClipping) {
		super(image, width, height, centerClipping);
	}

	public Image(BufferedImage image, IntRectangle textureClipping, float width, float height,
			IntOffset centerClipping) {
		super(image, textureClipping, width, height, centerClipping);
	}

	public Image(ObjectCount<Texture> background, float width, float height, IntOffset centerClipping) {
		super(background, width, height, centerClipping);
	}

	public Image(ObjectCount<Texture> background, IntRectangle textureClipping, float width, float height,
			IntOffset centerClipping) {
		super(background, textureClipping, width, height, centerClipping);
	}

	public Image(String background, float width, float height, IntOffset centerClipping) throws IOException {
		super(background, width, height, centerClipping);
	}

	public Image(String background, IntRectangle textureClipping, float width, float height, IntOffset centerClipping)
			throws IOException {
		super(background, textureClipping, width, height, centerClipping);
	}

	@Override
	protected DefaultTextureShader createDefaultTextureShader() {
		try {
			return AlphaTextureShader.getDefaultAlphaTextureShader();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
		return null;
	}

	@Override
	protected void glUseShader() {
		getDefaultTextureShader().glUseProgram();
		getDefaultTextureShader().glModelViewProjectMatrix();
		getDefaultTextureShader().glTexture(getBackground());
		((AlphaTextureShader) getDefaultTextureShader()).glAlpha(this.getAlpha());
	}
	
	public float getAlpha() {
		return alpha;
	}

	public void setAlpha(float alpha) {
		this.alpha = alpha;
	}

}
